#include<iostream>
#include<string>
#include<cstring>
using namespace std;
const int N = 4e3 + 10, M = N * 2;
int f1[N], f2[N];
int h[N], e[M], ne[M], idx;
int ans;
string s;
int n;
void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx++;
}
void dfs(int u, int f)
{
	if (s[u] == 'W')f1[u] = 1;
	else f2[u] = 1;
	for (int i = h[u]; ~i; i = ne[i]) {
		int j = e[i];
		if (j != f) {
			dfs(j, u);
			f1[u] += f1[j];
			f2[u] += f2[j];
			//if (f1[u] == f2[u])ans++;
		}
	}
}
int main()
{
	int t;
	cin >> t;
	while (t--) {
		cin >> n;
		idx = 0;
		ans = 0;
		memset(h, -1, sizeof(h));
		memset(e, 0, sizeof(e));
		memset(ne, 0, sizeof(ne));
		memset(f1, 0, sizeof(f1));
		memset(f2, 0, sizeof(f2));
		for (int i = 2; i <= n; i++) {
			int x;
			cin >> x;
			add(i, x);
			add(x, i);
		}
		cin >> s;
		s = " " + s;
		//cout << "==" << s[n+1] << endl;
		dfs(1, 0);
		for (int i = 1; i <= n; i++) {
			//cout << "i==" << i << "  f1==" << f1[i] << "  f2==" << f2[i] << endl;
			if (f1[i] == f2[i])ans++;
		}
		cout << ans << endl;
	}
	return 0;
}